Call CreateSitemap_Cat()
Call CreateSitemap_Items()

Sub CreateSitemap_Cat()
	Dim Arrs,XmlMessage,LoopI,DateTimeX
	XmlMessage ="<?xml version=""1.0"" encoding=""UTF-8""?>"& vbcrlf &"<urlset xmlns=""http://www.google.com/schemas/sitemap/0.84"">" & vbcrlf
	Arrs = GetRows("select A.[cat_id]  from [L_cat]  A where A.cat_other =0")
	For LoopI = 0 To UBound(Arrs,2)
		DateTimeX= GetOne("select top 1 info_time from l_info where cat_id =" & Arrs(0,LoopI) &" order by info_id desc")
		If(Len(DateTimeX)<6) Then DateTimeX =Now()

		XmlMessage = XmlMessage & "<url>"& vbcrlf &"<loc>"  & GetCatlogueURLPath(Arrs(0,LoopI)) & "</loc>" & vbcrlf
		XmlMessage = XmlMessage & "<changefreq>daily</changefreq>" & vbcrlf
		XmlMessage = XmlMessage & "<priority>0.6</priority>" & vbcrlf
		XmlMessage = XmlMessage & "<lastmod>"& ForSiteMapDateTime(cstr(DateTimeX)) &"</lastmod>" & vbcrlf
		XmlMessage = XmlMessage & "</url>"& vbcrlf
	Next 
	XmlMessage = XmlMessage & "</urlset>"
	Call WriteTo( Tpl.GetValue("BasePath") &   "sitemap_cats.xml",XmlMessage)
End Sub 
Sub CreateSitemap_Items()
	Dim Arrs,XmlMessage,LoopI,DateTimeX
	XmlMessage ="<?xml version=""1.0"" encoding=""UTF-8""?>"& vbcrlf &"<urlset xmlns=""http://www.google.com/schemas/sitemap/0.84"">" & vbcrlf
	Arrs = GetRows("select A.[info_id],A.[info_time],A.[cat_id],A.[info_path]  from [L_info]  A left join [l_Cat] B On A.cat_id = B.cat_id  where B.cat_other =0 order by A.[info_id] desc")
	For LoopI = 0 To UBound(Arrs,2)
		DateTimeX= GetOne("select top 1 reply_time from L_reply where info_id =" & Arrs(0,LoopI) &" order by reply_id desc")
		If(Len(DateTimeX)<6) Then DateTimeX =Arrs(1,LoopI)
		XmlMessage = XmlMessage & "<url>"& vbcrlf &"<loc>" &  GetCatlogueURLPath(Arrs(2,LoopI)) & Trim(Arrs(3,LoopI)) &  "</loc>" & vbcrlf
		XmlMessage = XmlMessage & "<changefreq>daily</changefreq>" & vbcrlf
		XmlMessage = XmlMessage & "<priority>0.5</priority>" & vbcrlf
		XmlMessage = XmlMessage & "<lastmod>"& ForSiteMapDateTime(DateTimeX) &"</lastmod>" & vbcrlf
		XmlMessage = XmlMessage & "</url>"& vbcrlf
	Next 
	XmlMessage = XmlMessage & "</urlset>"
	Call WriteTo(Tpl.GetValue("BasePath") & "sitemap_docs.xml",XmlMessage)
End Sub 
